package com.springcloud.demo.producer;

import com.springcloud.demo.channel.MySource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

@Component
//s@EnableBinding(MySource.class)
 @EnableBinding(Source.class)
public class MessageProducer {

    @Autowired
    private Source source;
//    @Autowired
//    private MySource source;

    /**
     * 发送消息
     *
     * @param message
     */
    public void send(String message) {
        source.output().send(MessageBuilder.withPayload(message).setHeader("xxx", 0).build());
        //source.output().send(MessageBuilder.withPayload(message).build());
        //source.outPut().send(MessageBuilder.withPayload(message).build());
    }

}
